<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
			var arr=['1','2','3','3','1']
			var a =[]
			for(key in arr){
				if(a.length){
					
					var flag = true;
					for(var i = 0 ; i<a.length;i++){
						if(arr[key] !== a[i]){
							flag = false;
						}
					}
					if(flag){
						a.push(arr[key])
						flag = true;
					}
				}else{
					a.push(arr[key])
				}
			}
			console.log(a)
			
		</script>
	</head>
	<body>
	</body>
</html>
